<template>
     <view style="height: 100%;margin-top: 100rpx;">
		<!-- @onPostMessage="load" -->
		<!-- #ifdef H5 -->
		<!-- <view class="iconfont icon-xiangzuo" @click="goback()"></view> -->
		<!-- #endif -->
		<hx-navbar :back="true" :fixed="false" :color="knavTitleColor" barPlaceholder="hidden"
			transparent="auto"></hx-navbar>
		<web-view :src="walletUrl" id="myWebView" @message="onMessage"></web-view>
	</view>

</template>

<script>

	export default {
		data() {
			return {
				walletUrl: ""
			}
		},
		onShow() {
			// uni.redirectTo({
				
			// })
		
		},
		onLoad(val) {
			//    //#ifdef APP-PLUS
			// console.log("appp-----")
			//          //#endif
			//          //#ifdef H5
			// 	  console.log("h5---------")
			//         // #endif
			// let style = {
			// statusbar: {
			// background:"#ffffff",
			// }
			// } 
			// // #ifdef APP
			// console.log("111-- -",val.url)
			// const wv = plus.webview.create(val.url,"",style);
			// wv.show()
			//// #endif
			
		let url = uni.getStorageSync('sdUrl');
			console.log(url)
			this.walletUrl = url
			// console.log('walletUrl', url)
			//app设置样式
			// #ifdef APP-PLUS
			var height = 0;
			uni.getSystemInfo({
				success: (sysinfo) => {
					height = sysinfo.windowHeight;
				},
				complete: () => {}
			});
			var currentWebview = this.$scope.$getAppWebview();
			setTimeout(function() {
				this.barHeight = plus.navigator.getStatusbarHeight();
				var wv = currentWebview.children()[0];
				wv.setStyle({
					top: this.barHeight,
					height: height - this.barHeight,
					scalable: true,
				})
			}, 500);
		
			// #endif
		},
	 
		  methods: { 
			  onMessage (event) {
			   console.log('web-view的---ai1-sd---：', event)
			   if (event.detail.data[0].action == 'reloadHome') {
			   	uni.setStorageSync('messageType', 'ai')
			   	uni.switchTab({
			   		url: `/pages/mart/mart`
			   	})
			   }
			   console.log('web-view的---ai-sd---：', event)
			      },
			  //监控url
			  recivePostMessag(e) {
			       console.log('web-view loaded------------', e)
			     //  this.url = e.mp.detail.src
			  			
			     },
			  goback() {
			        // #ifdef H5
			        return history.back();
			        // #endif
			        // #ifndef H5
			        return uni.navigateBack({
			          delta: 1,
			        })
			        // #endif
			      },
		
		    onLoad2(e) {
		        console.log('web-view message', e)
		     uni.setStorageSync('messageType', 'ai')
		     uni.switchTab({
		     	url: `/pages/mart/mart`
		     }) 
		      }
		   }
		  }
</script>

<style>

</style>